package com.hushan.elevator.utils;

public enum EventTypeEnum {
    TIMER_REPORT(0, "定时上报", EventTypeCategory.NORMAL),
    DOOR_CLOSE(4, "关门事件", EventTypeCategory.NORMAL),
    DOOR_OPEN(32, "开门事件", EventTypeCategory.NORMAL),
    MANUAL_TRIGGER(256, "手动触发事件", EventTypeCategory.NORMAL),
    REMOTE_MANUAL_CAPTURE(512, "远程手动抓拍事件", EventTypeCategory.NORMAL),
    FLOOR_ARRIVAL(16384, "楼层到达", EventTypeCategory.NORMAL),
    FLOOR_CHANGE(8388608, "楼层变化", EventTypeCategory.NORMAL),
    MAINTENANCE_MODE(536870912, "进入检修模式", EventTypeCategory.NORMAL),
    BATTERY_CAR_LEAVE(1024, "电瓶车离开事件", EventTypeCategory.NORMAL),

    BATTERY_CAR_TRIGGER(2, "电瓶车触发事件", EventTypeCategory.HUMAN_EXCEPTION),
    LONG_OPEN_DOOR(16, "长时间开门事件", EventTypeCategory.HUMAN_EXCEPTION),
    OVERLOAD_PERSONNEL(64, "人员超载事件", EventTypeCategory.HUMAN_EXCEPTION),
    CAMERA_OBSCURED(128, "镜头遮挡事件", EventTypeCategory.HUMAN_EXCEPTION),
    UNUSUAL_SOUND(2048, "异常声音（呼救）", EventTypeCategory.HUMAN_EXCEPTION),
    ELEVATOR_SHAKE(4096, "电梯抖动（电梯打闹）", EventTypeCategory.HUMAN_EXCEPTION),
    REPEAT_DOOR(262144, "反复开关门", EventTypeCategory.HUMAN_EXCEPTION),
    DESTROY_ELEVATOR(1048576, "破坏电梯", EventTypeCategory.HUMAN_EXCEPTION),
    GAS_CYLINDER_EVENT(33554432, "煤气罐事件", EventTypeCategory.HUMAN_EXCEPTION),
    EXTERNAL_TRIGGER(1, "外部触发事件", EventTypeCategory.HUMAN_EXCEPTION),

    TRAP_EVENT(8, "梯困事件", EventTypeCategory.ELEVATOR_EXCEPTION),
    OVERSPEED_EVENT(8192, "超速事件", EventTypeCategory.ELEVATOR_EXCEPTION),
    BUMP_TOP(32768, "冲顶事件", EventTypeCategory.ELEVATOR_EXCEPTION),
    DROP_BOTTOM(65536, "蹲底事件", EventTypeCategory.ELEVATOR_EXCEPTION),
    OPEN_DOOR_WALK(131072, "开门走梯事件", EventTypeCategory.ELEVATOR_EXCEPTION),
    NOBODY_HIGH_FREQ(524288, "无人高频运行", EventTypeCategory.ELEVATOR_EXCEPTION),
    FALL_ELEVATOR(2097152, "坠梯", EventTypeCategory.ELEVATOR_EXCEPTION),
    EMERGENCY_STOP(4194304, "急停", EventTypeCategory.ELEVATOR_EXCEPTION),
    NON_LEVEL_STOP(16777216, "非平层停", EventTypeCategory.ELEVATOR_EXCEPTION),
    POWER_OUTAGE_ALARM(67108864, "断电告警", EventTypeCategory.ELEVATOR_EXCEPTION),
    RUNNING_DOOR_LOCK_OPEN(134217728, "运行中门锁回路断开", EventTypeCategory.ELEVATOR_EXCEPTION),
    RUNNING_SAFE_CIRCUIT_OPEN(268435456, "运行中安全回路断开", EventTypeCategory.ELEVATOR_EXCEPTION);

    private final int code;
    private final String description;
    private final EventTypeCategory category;

    EventTypeEnum(int code, String description, EventTypeCategory category) {
        this.code = code;
        this.description = description;
        this.category = category;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public EventTypeCategory getCategory() {
        return category;
    }

    public static String getDescription(int code) {
        for (EventTypeEnum event : EventTypeEnum.values()) {
            if (event.getCode() == code) {
                return event.getDescription();
            }
        }
        return "未知事件";
    }

    public static EventTypeCategory getCategory(int code) {
        for (EventTypeEnum event : EventTypeEnum.values()) {
            if (event.getCode() == code) {
                return event.getCategory();
            }
        }
        return null;
    }
}